package com.xjy.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjy.common.core.mybatisplus.core.ServicePlusImpl;
import com.xjy.common.core.page.PagePlus;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.common.utils.PageUtils;
import com.xjy.system.domain.ReportProjBudget;
import com.xjy.system.domain.bo.ReportProjBudgetQueryBo;
import com.xjy.system.domain.vo.ReportProjBudgetVo;
import com.xjy.system.mapper.ReportProjBudgetMapper;
import com.xjy.system.service.IReportProjBudgetService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * VIEWService业务层处理
 *
 * @author mlb
 * @date 2022-03-17
 */
@Service
public class ReportProjBudgetServiceImpl extends ServicePlusImpl<ReportProjBudgetMapper, ReportProjBudget> implements IReportProjBudgetService {

    @Override
    public ReportProjBudgetVo queryById(Long projId){
        return getVoById(projId, ReportProjBudgetVo.class);
    }

    @Override
    public TableDataInfo<ReportProjBudgetVo> queryPageList(ReportProjBudgetQueryBo bo) {
        PagePlus<ReportProjBudget, ReportProjBudgetVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ReportProjBudgetVo.class);
        return PageUtils.buildDataInfo(result);
    }

    @Override
    public List<ReportProjBudgetVo> queryList(ReportProjBudgetQueryBo bo) {
        return listVo(buildQueryWrapper(bo), ReportProjBudgetVo.class);
    }

    private LambdaQueryWrapper<ReportProjBudget> buildQueryWrapper(ReportProjBudgetQueryBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ReportProjBudget> lqw = Wrappers.lambdaQuery();
        lqw.like(StrUtil.isNotBlank(bo.getProjName()), ReportProjBudget::getProjName, bo.getProjName());
        lqw.eq(StrUtil.isNotBlank(bo.getBudgetType()), ReportProjBudget::getBudgetType, bo.getBudgetType());
        return lqw;
    }


}
